home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MacApp / MacApp 3.0a2 / Libraries / UPrintHandler.cp < prev    next >
Encoding:
Text File  |  1991-05-01  |  8.9 KB  |  343 lines  |  [TEXT/MPS ]

  1. // UPrintHandler.cp
  2. // Copyright © 1985-1991 by Apple Computer, Inc.  All rights reserved.
  3.  
  4.  
  5. #ifndef __STDIO__
  6. #include <StdIo.h>
  7. #endif
  8.  
  9. #ifndef __UGEOMETRY__
  10. #include <UGeometry.h>
  11. #endif
  12.  
  13. #ifndef __BALLOONS__
  14. #include <Balloons.h>
  15. #endif
  16.  
  17. #ifndef __UVIEW__
  18. #include <UView.h>
  19. #endif
  20.  
  21. #ifndef __UFAILURE__
  22. #include <UFailure.h>
  23. #endif
  24.  
  25. #ifndef __UMACAPPUTILITIES__
  26. #include <UMacAppUtilities.h>
  27. #endif
  28.  
  29. #ifndef __UPATCH__
  30. #include <UPatch.h>
  31. #endif
  32.  
  33. #ifndef __DIALOGS__
  34. #include <Dialogs.h>
  35. #endif
  36.  
  37. #ifndef __UMACAPPGLOBALS__
  38. #include <UMacAppGlobals.h>
  39. #endif
  40.  
  41. #ifndef __ERRORS__
  42. #include <Errors.h>
  43. #endif
  44.  
  45. #ifndef __TOOLUTILS__
  46. #include <ToolUtils.h>
  47. #endif
  48.  
  49. #ifndef __UPRINTHANDLER__
  50. #include <UPrintHandler.h>
  51. #endif
  52.  
  53. //--------------------------------------------------------------------------------------------------
  54. Boolean gFinderPrintingProceed;            // proceed with Finder printing
  55.  
  56. //--------------------------------------------------------------------------------------------------
  57. #pragma segment PrintOpen
  58.  
  59. pascal void TPrintMenuBehavior::Initialize(void)        // override 
  60. {
  61.     inherited::Initialize();
  62.  
  63.     fPrintHandler = NULL;
  64. }
  65.  
  66. //--------------------------------------------------------------------------------------------------
  67. #pragma segment PrintOpen
  68.  
  69. pascal void TPrintMenuBehavior::IPrintMenuBehavior(TPrintHandler*    itsPrintHandler)
  70. {
  71.     this->IBehavior();
  72.  
  73.     fPrintHandler = itsPrintHandler;
  74. }
  75.  
  76. //--------------------------------------------------------------------------------------------------
  77. #pragma segment PrintRes
  78.  
  79. pascal void TPrintMenuBehavior::DoMenuCommand(CmdNumber aCmdNumber)
  80. {
  81.     // Can print if:
  82.     //  • have a print handler, and
  83.     //  • print handler has a view, and
  84.     //    either • view is not shown (e.g., Finder printing), or
  85.     //           • view is active.
  86.     // NOTE: we don't support printing of view's that are shown, but not active.
  87.  
  88.     // This algorithm allows a document to arbitrate between its various TPrintMenuBehavior objects,
  89.     // representing several printable views owned by the document.  This arbitration wasn't supported
  90.     // in MacApp prior to version 3.0.
  91.  
  92.     if (fPrintHandler && fPrintHandler->fView && (!fPrintHandler->fView->IsShown() || fPrintHandler->fView->IsActive()))
  93.     {
  94.         if (!fPrintHandler->DoPrintCommand(aCmdNumber))        // if we didn't print, call inherited
  95.             inherited::DoMenuCommand(aCmdNumber);
  96.     }
  97.     else
  98.         inherited::DoMenuCommand(aCmdNumber);
  99. }
  100.  
  101. //--------------------------------------------------------------------------------------------------
  102. #pragma segment PrintRes
  103.  
  104. pascal void TPrintMenuBehavior::DoSetupMenus()
  105. {
  106.     inherited::DoSetupMenus();
  107.  
  108.     // see note in TPrintMenuBehavior::DoMenuCommand
  109.     if (fPrintHandler && fPrintHandler->fView && fPrintHandler->fView->IsActive())
  110.         fPrintHandler->DoSetupPrintMenus();
  111. }
  112.  
  113. //--------------------------------------------------------------------------------------------------
  114. #pragma segment PrintOpen
  115.  
  116. pascal void TPrintHandler::Initialize(void)        // override 
  117. {
  118.     inherited::Initialize();
  119.     fDeviceRes = gZeroPt;                        //!!! Another default? 
  120.     fDocument = NULL;
  121.     fFocusedPage = 1;
  122.     fView = NULL;
  123.     fViewPerPage = gZeroVPt;                    //!!! Another default? 
  124. }
  125.  
  126. //--------------------------------------------------------------------------------------------------
  127. #pragma segment PrintOpen
  128.  
  129. pascal void TPrintHandler::IPrintHandler(TView* itsView)
  130. {
  131.     this->IViewBehavior();    // attaching to the view is handled by AttachPrintHandler
  132.     fView = itsView;
  133. }
  134.  
  135. //--------------------------------------------------------------------------------------------------
  136. #pragma segment MANever
  137.  
  138. pascal VCoordinate TPrintHandler::BreakFollowing(VHSelect/* vhs */,
  139.                                                  VCoordinate/* prevBreak */,
  140.                                                  Boolean&/* automatic */ )
  141.  
  142. {
  143. #if qDebug
  144.     ProgramBreak("BreakFollowing called for non-subclassed Printhandler");
  145. #endif
  146.  
  147.     return 0;
  148. }
  149.  
  150. //--------------------------------------------------------------------------------------------------
  151. #pragma segment MAFields
  152.  
  153. pascal void TPrintHandler::Fields(TObject* obj)
  154. {
  155.     obj->DoToField("TPrintHandler", NULL, bClass);
  156.     obj->DoToField("fView", &fView, bObject);
  157.     obj->DoToField("fDocument", &fDocument, bObject);
  158.     obj->DoToField("fDeviceRes", &fDeviceRes, bPoint);
  159.     obj->DoToField("fViewPerPage", &fViewPerPage, bVPoint);
  160.     obj->DoToField("fFocusedPage", &fFocusedPage, bInteger);
  161.  
  162.     inherited::Fields(obj);
  163. }
  164.  
  165. //--------------------------------------------------------------------------------------------------
  166. #pragma segment MANever
  167.  
  168. pascal void TPrintHandler::CalcPageStrips(VPoint&)
  169. {
  170. #if qDebug
  171.     ProgramBreak("CalcPageStrips called for non-subclassed Printhandler");
  172. #endif
  173. }
  174.  
  175. //--------------------------------------------------------------------------------------------------
  176. #pragma segment MANever
  177.  
  178. pascal void TPrintHandler::CalcViewPerPage(VPoint&)
  179. {
  180. #if qDebug
  181.     ProgramBreak("CalcViewPerPage called for non-subclassed Printhandler");
  182. #endif
  183. }
  184.  
  185. //--------------------------------------------------------------------------------------------------
  186. #pragma segment MANonRes
  187.  
  188. // See if there are changed printer-configuration parameters which
  189. // need to be absorbed, and if so, absorb them
  190. pascal void TPrintHandler::CheckPrinter(void)
  191. {
  192. }
  193.  
  194. //--------------------------------------------------------------------------------------------------
  195. #pragma segment MAPrintingRes
  196.  
  197. //Draw page-breaks, page-numbers, etc.
  198. pascal void TPrintHandler::DrawPrintFeedback(const VRect& area)
  199. {
  200. }
  201.  
  202. //--------------------------------------------------------------------------------------------------
  203. #pragma segment MAPrintingRes
  204.  
  205. pascal void TPrintHandler::DrawPageBreak(VHSelect vhs,
  206.                                          long whichBreak,
  207.                                          VCoordinate loc,
  208.                                          Boolean automatic)
  209. {
  210. }
  211.  
  212. //--------------------------------------------------------------------------------------------------
  213. #pragma segment MAPrintingRes
  214.  
  215. pascal void TPrintHandler::FocusOnInterior(void)
  216. {
  217. }
  218.  
  219. //--------------------------------------------------------------------------------------------------
  220. #pragma segment MAInspector
  221.  
  222. pascal void TPrintHandler::GetInspectorName(Str255& inspectorName)// override 
  223. {
  224.     Str255 hexString;
  225.  
  226.     if (this == gNullPrintHandler)
  227.         inspectorName = "gNullPrintHandler";
  228.     else if (this == gPrintHandler)
  229.         inspectorName = "gPrintHandler";
  230.     else if (IsObject(fView))
  231.     {
  232.         PointerToHex((long)(fView), hexString, 8);
  233.         inspectorName = "for view " + hexString;
  234.     }
  235. }
  236.  
  237. //--------------------------------------------------------------------------------------------------
  238. #pragma segment MAPrintingRes
  239.  
  240. pascal Handle TPrintHandler::GetPrintInfo(void)
  241. {
  242.     return NULL;
  243. }
  244.  
  245. //--------------------------------------------------------------------------------------------------
  246. #pragma segment MANever
  247.  
  248. pascal void TPrintHandler::LocatePageInterior(long pageNumber,
  249.                                               VPoint& loc)
  250. {
  251. }
  252.  
  253. //--------------------------------------------------------------------------------------------------
  254. #pragma segment MANever
  255.  
  256. pascal long TPrintHandler::MaxPageNumber(void)
  257. {
  258.     return 0;
  259. }
  260.  
  261. //--------------------------------------------------------------------------------------------------
  262. #pragma segment MAPrint
  263.  
  264. pascal void TPrintHandler::Print(CmdNumber,
  265.                                  Boolean& proceed)
  266. {
  267.     proceed = TRUE;
  268. }
  269.  
  270. //--------------------------------------------------------------------------------------------------
  271. #pragma segment MANonRes
  272.  
  273. pascal void TPrintHandler::PrinterChanged(void)
  274.  
  275. {
  276. }
  277.  
  278. //--------------------------------------------------------------------------------------------------
  279. #pragma segment MAFinder
  280. //??? Signal error ???
  281.  
  282. pascal Boolean TPrintHandler::SetupForFinder(void)
  283. {
  284. #if qDebugMsg
  285.     fprintf(stderr, "SetupForFinder called for a view that can't");
  286. #endif
  287.  
  288.     return FALSE;
  289. }
  290.  
  291. //--------------------------------------------------------------------------------------------------
  292. #pragma segment MANever
  293.  
  294. pascal void TPrintHandler::RedoPageBreaks(void)
  295. {
  296. }
  297.  
  298. //--------------------------------------------------------------------------------------------------
  299. #pragma segment MANever
  300.  
  301. pascal void TPrintHandler::Reset(void)
  302. {
  303. }
  304.  
  305. //--------------------------------------------------------------------------------------------------
  306. #pragma segment MANever
  307.  
  308. pascal Boolean TPrintHandler::DoPrintCommand(CmdNumber /* aCmdNumber */)
  309. {
  310.     return FALSE;
  311. }
  312.  
  313. //--------------------------------------------------------------------------------------------------
  314. #pragma segment MANever
  315.  
  316. pascal void TPrintHandler::DoSetupPrintMenus()
  317. {
  318. }
  319.  
  320. //--------------------------------------------------------------------------------------------------
  321. #pragma segment PrintOpen
  322.  
  323. // Meant to be overridden in a subclass that really prints 
  324. pascal void TPrintHandler::SetDefaultPrintInfo(void)
  325. {
  326. }
  327.  
  328. //--------------------------------------------------------------------------------------------------
  329. #pragma segment MANever
  330.  
  331. pascal void TPrintHandler::SetPageInterior(long pageNumber)
  332. {
  333. }
  334.  
  335. //--------------------------------------------------------------------------------------------------
  336. #pragma segment MANever
  337.  
  338. pascal void TPrintHandler::SetPageOffset(const VPoint& coord)
  339. {
  340. }
  341.  
  342.  
  343.